<template>
  <div>
    <el-row>
      <el-col :span="21">
        <el-input v-model="input" placeholder="请输入代办事项" @keydown.enter="add()" />
      </el-col>
      <el-col :span="3">
        <el-button type="primary" round @click="add">添加任务</el-button></el-col
      >
    </el-row>
  </div>
</template>

<script>
import { h } from 'vue'
import { ElNotification } from 'element-plus'
export default {
  data() {
    return {
      input: "",
    };
  },
  methods: {
    add() {
      if (this.input != "") {
        this.$emit("add", this.input);
      }
      else
      {
        ElNotification({
        title: 'Title',
        message: h('i', { style: 'color: teal' }, '请输入待办事项(不能为空哦！)'),})
      }
      this.input = "";
    },
  },
};
</script>
